/*     */ package com.zimbra.cs.redolog.op;
/*     */ 
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.cs.mailbox.MailServiceException;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.mailbox.MailboxManager;
/*     */ import com.zimbra.cs.mailbox.MailboxOperation;
/*     */ import com.zimbra.cs.redolog.RedoLogInput;
/*     */ import com.zimbra.cs.redolog.RedoLogOutput;
/*     */ import com.zimbra.cs.redolog.Version;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class CreateLink
/*     */   extends RedoableOp
/*     */ {
/*     */   private int mId;
/*     */   private String mUuid;
/*     */   private int mFolderId;
/*     */   private String mName;
/*     */   private String mOwnerId;
/*     */   private int mRemoteId;
/*     */   
/*     */   public CreateLink()
/*     */   {
/*  38 */     super(MailboxOperation.CreateMountpoint);
/*  39 */     this.mId = 0;
/*     */   }
/*     */   
/*     */   public CreateLink(int mailboxId, int folderId, String name, String ownerId, int remoteId) {
/*  43 */     this();
/*  44 */     setMailboxId(mailboxId);
/*  45 */     this.mId = 0;
/*  46 */     this.mFolderId = folderId;
/*  47 */     this.mName = (name != null ? name : "");
/*  48 */     this.mOwnerId = ownerId;
/*  49 */     this.mRemoteId = remoteId;
/*     */   }
/*     */   
/*     */   public int getId() {
/*  53 */     return this.mId;
/*     */   }
/*     */   
/*     */   public String getUuid() {
/*  57 */     return this.mUuid;
/*     */   }
/*     */   
/*     */   public void setIdAndUuid(int id, String uuid) {
/*  61 */     this.mId = id;
/*  62 */     this.mUuid = uuid;
/*     */   }
/*     */   
/*     */   protected String getPrintableData()
/*     */   {
/*  67 */     StringBuilder sb = new StringBuilder("id=").append(this.mId);
/*  68 */     sb.append(", uuid=").append(this.mUuid);
/*  69 */     sb.append(", name=").append(this.mName).append(", folder=").append(this.mFolderId);
/*  70 */     sb.append(", owner=").append(this.mOwnerId).append(", remote=").append(this.mRemoteId);
/*  71 */     return sb.toString();
/*     */   }
/*     */   
/*     */   protected void serializeData(RedoLogOutput out) throws IOException
/*     */   {
/*  76 */     out.writeInt(this.mId);
/*  77 */     if (getVersion().atLeast(1, 37)) {
/*  78 */       out.writeUTF(this.mUuid);
/*     */     }
/*  80 */     out.writeUTF(this.mName);
/*  81 */     out.writeUTF(this.mOwnerId);
/*  82 */     out.writeInt(this.mRemoteId);
/*  83 */     out.writeInt(this.mFolderId);
/*     */   }
/*     */   
/*     */   protected void deserializeData(RedoLogInput in) throws IOException
/*     */   {
/*  88 */     this.mId = in.readInt();
/*  89 */     if (getVersion().atLeast(1, 37)) {
/*  90 */       this.mUuid = in.readUTF();
/*     */     }
/*  92 */     this.mName = in.readUTF();
/*  93 */     this.mOwnerId = in.readUTF();
/*  94 */     this.mRemoteId = in.readInt();
/*  95 */     this.mFolderId = in.readInt();
/*     */   }
/*     */   
/*     */   public void redo() throws Exception
/*     */   {
/* 100 */     int mboxId = getMailboxId();
/* 101 */     Mailbox mailbox = MailboxManager.getInstance().getMailboxById(mboxId);
/*     */     try
/*     */     {
/* 104 */       mailbox.createLink(getOperationContext(), this.mFolderId, this.mName, this.mOwnerId, this.mRemoteId);
/*     */     } catch (MailServiceException e) {
/* 106 */       if (e.getCode() == "mail.ALREADY_EXISTS") {
/* 107 */         if (mLog.isInfoEnabled()) {
/* 108 */           mLog.info("Link " + this.mId + " already exists in mailbox " + mboxId);
/*     */         }
/*     */       } else {
/* 111 */         throw e;
/*     */       }
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/CreateLink.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */